package com.reflect;

public class ReflectServiceImpl {
    public void sayGood(){
        System.out.println("hello good");
    }

    //利用反射实例化对象
    public ReflectServiceImpl getInstance(){

        ReflectServiceImpl reflectService = null;
        try {
            try {
                reflectService = (ReflectServiceImpl) Class.forName("com.reflect.ReflectServiceImpl").newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            }
        } catch (ClassNotFoundException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return reflectService;
    }

}

